<!-- 音频上传开始 -->
<div>
	<button type="button" class="layui-btn  layui-btn-sm" onclick="uploadAudio{$id}()"><i class="layui-icon"></i>上传音频</button>
</div>
<div class="layui-form" id="uploadAudio{$id}" style="display:none;margin-top: 15px!important;font-size:12px;">
   <div class="layui-form-item">
	    <label class="layui-form-label">本地音频</label>
	    <div class="layui-upload nc-len-long">
			  <button type="button" class="layui-btn"  id="audio{$id}"><i class="layui-icon"></i>音频上传</button>
			  <blockquote class="layui-elem-quote layui-quote-nm">
			     预览：<div class="layui-upload-list" id="audioShow{$id}"></div>
			  </blockquote>
			  <div>仅支持 amr、 mp3、 mpeg 3种格式, 大小不超过6.0 MB</div>
		</div>
  </div>
  <div class="nc-form-row">
	   <button type="button" class="layui-btn" id="btnAudio{$id}">保存</button>
	  <button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
  </div>
</div>
<!-- 音频上传结束 -->
<script>
//音频
function uploadAudio{$id}(){
	layer.open({
		type: 1,
		area: ['850px'], //宽高
		content: $('#uploadAudio{$id}'),
		cancel: function () {
			//右上角关闭回调
			$("#uploadAudio{$id}").hide();
			//return false 开启该代码可禁止点击该按钮关闭
		}
	});
}

layui.use('upload', function(){
	var upload = layui.upload;
	//音频
	upload.render({
		elem: '#audio{$id}'
		,url: '{:addon_url("File://common/File/audio")}'
		,accept: 'audio' //音频
		,data: {category_id: function(){return $(".active>.category-id").val();}}
		,auto: false
		,bindAction: '#btnAudio{$id}'
		,choose: function(obj){
		      //预读本地文件示例，不支持ie8
		      obj.preview(function(index, file, result){
		        $('#audioShow{$id}').append('<embed height="100" width="100" src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img"/>')
		      });
		 }
		,done: function(res){
			location.reload();
		}
	});

});
</script>